﻿//***********************************************************************
// Assembly         : IGolovkine.AoA.Tests
// Author           : Ilia
// Created          : 06-11-2011
//
// Last Modified By : Ilia
// Last Modified On : 01-04-2010
// Description      : 
//
// Copyright        : (c) Microsoft. All rights reserved.
//***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace IGolovkine.AoA.Tests
{
    public static class AssertEX
    {
        public static void Throws<E>(Action action) where E : Exception
        {
            try
            {
                action();
                Assert.Fail("Exception of type {0} was not thrown", typeof(E).Name);
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Assert.AreEqual(typeof(E), ex.GetType());
            }
        }
        public static void AreEqual<T>(IEnumerable<T> arr1, IEnumerable<T> arr2)
        {
            Assert.IsNotNull(arr1);
            Assert.IsNotNull(arr2);

            Assert.AreEqual(arr1.Count(), arr2.Count());

            for (int i = 0; i < arr1.Count(); i++)
            {
                Assert.AreEqual(arr1.ElementAt(i), arr2.ElementAt(i));
            }
        }
        public static void AreEqual<T>(T[] arr1, T[] arr2)
        {
            Assert.IsNotNull(arr1);
            Assert.IsNotNull(arr2);
            
            Assert.AreEqual(arr1.Length, arr2.Length);

            for (int i = 0; i < arr1.Length; i++)
            {
                Assert.AreEqual(arr1[i], arr2[i]);
            }
        }
    }
}
